<template>
	<uni-popup ref="popup" type="bottom">
		<view class="popub_box uni-white-bg">
			<view class="full-w header_item disp flex-row center around basic-label">
				<view class="left_btn btns full-h" @click="hide">取消</view>
				<view class="title_info flex1 full-h">{{title}}</view>
				<view class="right_btn full-h basic-label d14 btns" @click="sure">确定</view>
			</view>	
			<picker-view class="picker-views" :indicator-style="indicatorStyle" :value="value" @change="bindDateChange">
				<picker-view-column>
					<view class="uni-datetime-picker-item" v-for="(item,index) in picker" :key="index">
						<text class="uni-datetime-picker-item">{{item.roleName}}</text>
					</view>
				</picker-view-column>
			</picker-view>
		</view>
	</uni-popup>
</template>
<script>
	export default {
		props: {
			title: String,
			picker: {
				type: Array,
				default: () => []
			},
			value: {},
			label: {
				type: String,
				default: "label"
			}
		},
		data() {
			return {
				indicatorStyle: `height: 50px;`,
				check: 0,
			}
		},
		methods: {
			show() {
				this.$refs.popup.open();
			},
			hide() {
				this.$refs.popup.close();
			},
			bindDateChange({detail}) {
				this.check = detail.value[0];
			},
			sure() {
				this.$emit("sure", this.picker[this.check]);
				this.hide();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.picker-views {
		height: 600rpx;
	}
	.uni-datetime-picker-item {
		text-align: center;
		line-height: 50px;
	}
	.header_item {
		height: 80rpx;
		border-bottom: solid 2rpx #eee;
		line-height: 80rpx;
		.btns {
			width: 120rpx;
			padding: 0 20rpx;
			line-height: 80rpx !important;
		}
		.title_info {
			text-align: center;
		}
		.right_btn {
			text-align: right;
		}
	}
</style>